﻿<?xml version="1.0" encoding="utf-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html>
<!-- saved from url=(0033)http://research.microsoft.com/pex -->
<head><link rel="StyleSheet" href="er.common.css" type="text/css" /><script src="er.common.js" type="text/javascript"> </script><link rel="SHORTCUT ICON" href="favicon.ico" /><link rel="icon" href="favicon.ico" type="image/x-icon" /><title>C:\Users\AO\Documents\Visual Studio 2010\AutomaTones3\automatones\AutomaTones\AutomaTones\HW Sense Compute\SenseLaunchpad.cs</title></head><body><div class="banner"></div><h2 id="top">C:\Users\AO\Documents\Visual Studio 2010\AutomaTones3\automatones\AutomaTones\AutomaTones\HW Sense Compute\SenseLaunchpad.cs</h2><div class="toggle"><p class="copyright"><a class="usercodeundertestcovered">user code under test</a>, 
  <span class="usercodeundertestnotcovered">user code under test (not covered)</span>, 
  <a class="userortestcodecovered">user code or test</a>, 
  <span class="userortestcodenotcovered">user code or test (not covered)</span>,
  <span class="tagged">tagged</span></p><table><tr><th>Methods</th></tr><tr><th /></tr></table><div class="toggle"><a class="button" href="#ID0EL">first</a><pre class="coverage">using Midi;
using System.Diagnostics.Contracts;
using Microsoft.Pex.Framework;

namespace AutomaTones.HW_Sense_Compute {
    /// &lt;summary&gt;
    /// Starts sensing the incoming Midi messages and forwards these messages, which is handled by ComputeLaunchpad.
    /// This class is part of the Hardware, Sense, Compute Pattern.
    /// &lt;/summary&gt;
    /// &lt;author&gt;Anders Bech Mellson, anbh@itu.dk&lt;/author&gt;
    [PexClass]
    class SenseLaunchpad : ISense {
        private readonly InputDevice _launchpadIn;
        public readonly ComputeLaunchpad ComputeLaunchpad;

        /// &lt;summary&gt;
        /// Creates a connection to the Launchpad.
        /// &lt;/summary&gt;
        <span id="ID0EL"><a class="button" href="#top">top</a>|<a class="button" href="#ID0EJAAC">next</a></span><a class="userortestcodecovered">public SenseLaunchpad()</a> <a class="userortestcodecovered">{</a>
            Contract.Requires(!ConnectLaunchpad.In.IsOpen);
            <a class="userortestcodecovered">_launchpadIn = ConnectLaunchpad.In;</a>
            <a class="tagged" title="call to uninstrumented method InputDevice.Open()">_launchpadIn.Open();</a>
            <a class="tagged" title="call to uninstrumented method InputDevice.add_NoteOn(NoteOnHandler)">_launchpadIn.NoteOn += PadPressed;</a>
            <a class="tagged" title="call to uninstrumented method InputDevice.add_ControlChange(ControlChangeHandler)">_launchpadIn.ControlChange += ControlButtonPressed;</a>
            <a class="userortestcodecovered">ComputeLaunchpad = new ComputeLaunchpad();</a>
        <a class="userortestcodecovered">}</a>

        /// &lt;summary&gt;
        /// Starts sensing on the connected Launchpad.
        /// &lt;/summary&gt;
        [PexMethod]
        public void StartSensing() <a class="button" href="#ID0EL">prev</a>|<span id="ID0EJAAC"><a class="button" href="#top">top</a></span><a class="userortestcodecovered">{</a>
            <a class="tagged" title="call to uninstrumented method InputDevice.StartReceiving(Clock)">_launchpadIn.StartReceiving(null);</a>
        <a class="userortestcodecovered">}</a>

        /// &lt;summary&gt;
        /// Sends a NoteOnMessage to ComputeLaunchpad.
        /// &lt;/summary&gt;
        /// &lt;param name="msg"&gt;&lt;/param&gt;
        private void PadPressed(NoteOnMessage msg) {
            ComputeLaunchpad.Compute(msg);
        }

        /// &lt;summary&gt;
        /// Sends a ControlChangeMessage to ComputeLaunchpad.
        /// &lt;/summary&gt;
        /// &lt;param name="msg"&gt;&lt;/param&gt;
        private void ControlButtonPressed(ControlChangeMessage msg) {
            ComputeLaunchpad.ControlButton(msg);
        }
    }
}
</pre></div></div><hr /><table width="100%"><tr><td valign="top"><span class="copyright">Copyright (c) Microsoft Corporation. All rights reserved.</span><br /><span class="button" onclick="copySourceToClipboard()">Copy full source to clipboard</span></td></tr></table><div id="debugdiv"> </div></body></html>